﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Data;

namespace ESC.Designer.Resources
{
    public class BeiHuoCreateTaskColorConvert : IMultiValueConverter
    {
        public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var green = System.Windows.Media.Color.FromRgb(0x00, 0x64, 0x00);
            var yello = System.Windows.Media.Color.FromRgb(0xff, 0x99, 0x00);
            var red = System.Windows.Media.Color.FromRgb(0xff, 0x00, 0x00);
            try
            {
                decimal d1 = System.Convert.ToDecimal(value[0]);
                decimal d2 = System.Convert.ToDecimal(value[1]);
                int stat = System.Convert.ToInt32(value[2]);
                if (stat == 2)
                    return new System.Windows.Media.SolidColorBrush(green);
                else if (d1 < d2)
                {
                    return new System.Windows.Media.SolidColorBrush(yello);
                }
                else
                {
                    return new System.Windows.Media.SolidColorBrush(red);
                }
            }
            catch
            {
                return new System.Windows.Media.SolidColorBrush(red);

            }
        }

        public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
